<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script src="./lib/echarts.min.js"></script>
  </head>
  <body>
    <!-- 为 ECharts 准备一个定义了宽高的 DOM -->
    <div id="main" style="width: 600px; height: 400px"></div>
    <script>
      // 基于准备好的dom，初始化echarts实例
      var myChart = echarts.init(document.getElementById("main"));
      const data = [
        {
          name: "2万以上",
          value: 2,
        },
        {
          name: "1万以下",
          value: 0.5,
        },
        {
          name: "1.5万",
          value: 1.5,
        },
        {
          name: "1.5万以上",
          value: 1.5,
        },
      ];
      option = {
        title: [
          {
            text: "男女薪资分布图",
            // left: 'center'
          },
          {
            subtext: "男生",
            left: "center",
            top: "40%",
            subtextStyle: {
              color: "black",
              fontStyle: "bold",
              fontSize: 16,
            },
          },
          {
            subtext: "女生",
            left: "center",
            bottom: "8%",
            subtextStyle: {
              color: "black",
              fontStyle: "bold",
              fontSize: 16,
            },
          },
        ],
        tooltip: {
          trigger: "item",
        },
        series: [
          {
            type: "pie",
            radius: ["20%", "25%"],
            center: ["50%", "70%"],
            data: data,
            label: {
              position: "outer",
              alignTo: "none",
              bleedMargin: 5,
            },
            left: 0,
            right: 0,
            top: 0,
            bottom: 0,
          },
          {
            type: "pie",
            radius: ["20%", "25%"],
            center: ["50%", "25%"],
            data: data,
            label: {
              position: "outer",
              alignTo: "labelLine",
              bleedMargin: 5,
            },
            left: 0,
            right: 0,
            top: 0,
            bottom: 0,
          },
        ],
        color: ["#5097ff", "#3fceff", "#34d39a", "#fda224"],
      };
      myChart.setOption(option);
      // 使用刚指定的配置项和数据显示图表。
      myChart.setOption(option);
    </script>
  </body>
</html>
